import Group from "../entities/Group";
import Operator from "./Operator";
import { RC } from "../config/RC";


class CheckGroupIdExistOperator extends Operator {
    public async execute(): Promise<RC> {
        try {
            const group_id: string = this.args.getProperty('groupId');
            if (group_id === '' || group_id === null || group_id === undefined) {
                return RC.INVALID_ARGUMENT;
            }
            const isExist = await Group.CheckGroupIdExist(group_id);
            if (isExist) return RC.SUCCESS;
            else return RC.GROUPID_NOTEXIST;
        } catch (error) {
            // 处理异常情况
            console.error('Error checking group existence:', error);
            return RC.INTERNAL_ERROR;
        }
    }
}

export default CheckGroupIdExistOperator;